package com.lujieni.threadpool.task;

import com.alibaba.fastjson.JSON;
import com.lujieni.threadpool.po.ThreadPoolTaskPO;
import java.util.concurrent.TimeUnit;

/**
 * @Author：小鹿爱吃鱼
 * @Date: 2025/2/23 18:01
 * @Description:
 */
public class SayContentTask implements Runnable{

    private final String input;

    private Long id;

    public static final String TASK_TYPE = "1";

    public static final String POOLNAME = "sayContentThreadPool";


    @Override
    public void run() {
        try {
            TimeUnit.SECONDS.sleep(20);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(input);
    }

    public SayContentTask(Long id, String input) {
        this.id = id;
        this.input = input;
    }

    @Override
    public String toString() {
        ThreadPoolTaskPO taskPO = new ThreadPoolTaskPO();
        taskPO.setId(id);
        taskPO.setTaskType(TASK_TYPE);
        taskPO.setInput(input);
        taskPO.setPoolname(POOLNAME);
        return JSON.toJSONString(taskPO);
    }
}
